﻿namespace System.Web.Mvc
{
    using System.Collections.Generic;

    internal sealed class ScriptData
    {
        private List<string> scriptReferences;
        private List<string> scriptBlocks;

        private List<ScriptBehavior> scriptBehaviors;

        private int counter;

        public ScriptData()
        {
            this.scriptReferences = new List<string>();
            this.scriptBehaviors = new List<ScriptBehavior>();
            this.scriptBlocks = new List<string>();
        }

        public ICollection<ScriptBehavior> ScriptBehaviors
        {
            get
            {
                return this.scriptBehaviors;
            }
        }

        public ICollection<string> ScriptReferences
        {
            get
            {
                return this.scriptReferences;
            }
        }

        public ICollection<string> ScriptBlocks
        {
            get
            {
                return this.scriptBlocks;
            }
        }

        public int Counter
        {
            get
            {
                return this.counter;
            }
        }

        public void DecrementCounter()
        {
            this.counter--;
        }

        public void IncrementCounter()
        {
            this.counter++;
        }

        public void RegisterScript(string scriptPath)
        {
            if (!this.scriptReferences.Contains(scriptPath))
            {
                this.scriptReferences.Add(scriptPath);
            }
        }

        public void RegisterScriptBehavior(ScriptBehavior behavior)
        {
            this.scriptBehaviors.Add(behavior);
        }

        public void RegisterScriptBlock(string script)
        {
            this.scriptBlocks.Add(script);
        }
    }
}
